
.PHONY : flash

OPENOCD_PATH = $(dir $(shell which openocd))..

ifeq ($(PLAT), stm32f10x)
TARGET_CONFIG_FILE = stm32f1x.cfg
endif

flash:
	$(Q)$(OPENOCD_PATH)/bin/openocd \
	-f $(OPENOCD_PATH)/share/openocd/scripts/interface/jlink.cfg \
	-f $(OPENOCD_PATH)/share/openocd/scripts/target/$(TARGET_CONFIG_FILE) \
	-c init -c halt -c "flash write_image erase $(TARGET_HEX)" -c reset -c shutdown
